From: Dan Nicholson Date: Tue, 9 Aug 2016 18:45:25 +0000 (-0700) Subject: deltas: Handle cleanup of fd array properly X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~48^2~32 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=1e5ff71c498f85af209ccaf0eee3c4cff26f21ac;p=ostree.git deltas: Handle cleanup of fd array properly If there's an early error, part_temp_fds will be NULL and dereferencing the len member will segfault. Closes: #454 Closes: #448 Approved by: cgwalters --- diff --git a/src/libostree/ostree-repo-static-delta-compilation.c b/src/libostree/ostree-repo-static-delta-compilation.c index 8b388094..7ef7680d 100644 --- a/src/libostree/ostree-repo-static-delta-compilation.c +++ b/src/libostree/ostree-repo-static-delta-compilation.c @@ -1584,13 +1584,14 @@ ostree_repo_static_delta_generate (OstreeRepo *self, ret = TRUE; out: - for (i = 0; i < part_temp_fds->len; i++) - { - int fd = g_array_index (part_temp_fds, int, i); - if (fd == -1) - continue; - (void) close (fd); - } + if (part_temp_fds) + for (i = 0; i < part_temp_fds->len; i++) + { + int fd = g_array_index (part_temp_fds, int, i); + if (fd == -1) + continue; + (void) close (fd); + } g_clear_pointer (&builder.parts, g_ptr_array_unref); g_clear_pointer (&builder.fallback_objects, g_ptr_array_unref); return ret;